﻿<local:ItemForm x:Class="WpfApp1.Views.Orders.OrderHistory.OrderHistoryItem"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp1.Views"
        mc:Ignorable="d"
        ResizeMode="NoResize"
        Icon="\Resources\wb.ico"
        Height="450" Width="488"
        Loaded="ItemForm_Loaded" Closing="ItemForm_Closing">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="50"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" Grid.ColumnSpan="3">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="43"/>
                <RowDefinition Height="43"/>
                <RowDefinition Height="43"/>
                <RowDefinition Height="43"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Label Grid.Column="0" Grid.Row="0" Content="Id заказа" VerticalAlignment="Center"/>
            <TextBox x:Name="tbId" 
                     Width="310"
                     Grid.Column="1"
                     Grid.Row="0"
                     IsReadOnly="True"
                     HorizontalAlignment="Left"
                     Margin="0 5" 
                     TextChanged="tbId_TextChanged"
                     Text="{Binding CurrentItem.OrderId }" 
                     Style="{StaticResource CommonTextBox}">
            </TextBox>

            <Label Grid.Column="0" Grid.Row="1" Content="Товар" VerticalAlignment="Center"/>
            <ComboBox x:Name="cbProduct"
                      Grid.Row="1"
                      Grid.Column="1" 
                      Style="{StaticResource CommonComboBox}"
                      Width="310" 
                      IsEnabled="False"
                      HorizontalAlignment="Left"
                      SelectedValue="{Binding CurrentItem.Product, Mode=TwoWay}">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Label Content="{Binding Id}"/>
                            <Label Content="{Binding Title}"/>
                        </StackPanel>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>

            <TextBlock Margin="5 0" Grid.Column="0" Grid.Row="2" Text="Статус заказа" TextWrapping="Wrap" VerticalAlignment="Center"/>
            <ComboBox x:Name="cbStatus"
                      Grid.Row="2"
                      Grid.Column="1" 
                      Style="{StaticResource CommonComboBox}"
                      Width="310" 
                      HorizontalAlignment="Left"
                      SelectedValue="{Binding CurrentItem.Status}">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Label Content="{Binding Description}"/>
                        </StackPanel>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>

            <Label Grid.Column="0" Grid.Row="3" Content="Склад" VerticalAlignment="Center"/>
            <ComboBox x:Name="cbStorage"
                      Grid.Row="3"
                      Grid.Column="1" 
                      Style="{StaticResource CommonComboBox}"
                      Width="310" 
                      HorizontalAlignment="Left"
                      SelectedValue="{Binding CurrentItem.Order.PickUpPoint}">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Label Content="{Binding Id}"/>
                            <Label Content="{Binding Country}"/>
                            <Label Content="{Binding FederalSubject}"/>
                            <Label Content="{Binding Locality}"/>
                            <Label Content="{Binding Street}"/>
                            <Label Content="{Binding HouseNumber}"/>
                        </StackPanel>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>

            <ScrollViewer Grid.ColumnSpan="2" Grid.Row="4" Margin="10" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible">
                <UserControl x:Name="ucSection" />
            </ScrollViewer>
            
        </Grid>
        <DockPanel Grid.Row="1"  Margin="10" Grid.ColumnSpan="3">
            <Button x:Name="btnDataAction" Margin="10 0" Width="90" HorizontalAlignment="Left" Template="{StaticResource commonButton}" Command="{Binding SaveCommand}">Сохранить</Button>
            <Button x:Name="btnClose" Margin="10 0" Width="90" HorizontalAlignment="Right" Template="{StaticResource commonButton}" Click="btnClose_Click">Закрыть</Button>
        </DockPanel>
    </Grid>
</local:ItemForm>
